<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        /* 编写一个函数，计算任意数字的和、差、积、商
         要求：使用传参的形式 */
        var num1 = prompt('请输入数字') - 0
        var num2 = prompt('请输入数字') - 0
        fn(num1, num2)

        function fn(a, b) {
            if (a / 1 === a && b / 1 === b) {
                console.log(a + '+' + b + '=' + (a + b))
                console.log(a + '-' + b + '=' + (a - b))
                console.log(a + '*' + b + '=' + (a * b))
                if (b === 0) {
                    console.log('被除数为0毫无意义，请重新输入')
                } else {
                    console.log(a + '/' + b + '=' + (a / b))
                }
            } else {
                console.log("请输入数字")
            }
        }
    </script>
</body>

</html>